<!--根据物品选择物品所在的库位组件-->
<template>
  <div>
    <div
        class="search-content wrap-apply"
        :show="columnsData.listShow"
        :style="{
        top: GLOBAL.currentEnvironment ? '0!important' : '',
        height: GLOBAL.currentEnvironment ? '100vh' : 'calc(100vh - 1.12rem)',
        paddingBottom: GLOBAL.currentEnvironment ? '0.66rem' : '',
      }"
    >
      <div class="nav_bar">
        <van-nav-bar
            :title="columnsData.title"
            left-arrow
            fixed
            placeholder
            @click-left="goBack"
        />
      </div>

      <div class="action">
        <div class="title">
          <slot name="title"></slot>
        </div>
        <div
            class="listBox"
            :style="{
            height: GLOBAL.currentEnvironment
              ? '100vh'
              : 'calc(100vh - 3.12rem)',
            paddingBottom: GLOBAL.currentEnvironment ? '0.66rem' : '',
          }"
        >

          <!--出库库位物品的信息-->
          <div class="list" v-if="columnsData.isSelectAll||selectLattice">
            <div class="wrap" >
              <div class="pd">
                <div class="top">
                  <div class="title titleWidth">
                    {{ columnsData.query.goodsCode }} | {{ columnsData.query.goodsName }} |
                    {{ columnsData.query.spec }}
                  </div>
                </div>
                <div class="center">
                  <div>
                    <p>
                      <span class="key">包装规格：</span>
                      <span class="value">{{ columnsData.query.packageSpec || "-" }}</span>
                    </p>
                    <p>
                      <span class="key">产地：</span>
                      <span class="value">{{ columnsData.query.address || "-" }}</span>
                    </p>
                  </div>
                </div>
                <div class="label" style="padding: 0;display: flex;justify-content: space-between;">
                  <div>
                    <span>{{ columnsData.query.produceDate || "-" }}</span>
                    <span>{{ columnsData.query.batchCode || "-" }}</span>
                    <span>{{ columnsData.query.unitName || columnsData.query.unitIdText || '-' }}</span>
                  </div>
                  <div style="font-size: 10px;color: #666">
                    共{{ columnsData.len || 0 }}，合计 {{ columnsData.total.toLocaleString() || 0 }}
                  </div>
                </div>
              </div>
            </div>
          </div>

          <!--出库物品库位的信息-->
          <div class="list" v-else>
            <div class="wrap" style="display: flex;justify-content: space-between;">
              <div class="title titleWidth">
                {{ columnsData.query.latticeCode }} | {{ columnsData.query.latticeName }}
              </div>
              <div style="font-size: 10px;color: #666">
                共{{ columnsData.len || 0 }}，合计 {{ columnsData.total.toLocaleString() || 0 }}
              </div>
            </div>
          </div>
          <!--列表信息-->
          <pageList
              ref="pageList"
              :checkedShow="columnsData.checkedShow"
              :operationTxt="columnsData.operationTxt"
              :columns="columnsData.columns"
              checkedShowText="全选"
              cancelOperationTxt=""
              :listUrl="columnsData.listUrl"
              @getCheckedValue="getCheckedValue"
              @handleList="handleList"
              @operationItem="operationItem"
              @listData="listData"
          >
            <div
                slot="head"
                v-if="columnsData.columns.headSlot"
                slot-scope="{ item, index }"
            >
              <slot name="head" :item="item" :index="index"></slot>
            </div>
            <div
                slot="body"
                v-if="columnsData.columns.bodySlot"
                slot-scope="{ item, index }"
            >
              <slot name="body" :item="item" :index="index"></slot>
            </div>
            <div
                slot="label"
                v-if="columnsData.columns.labelSlot"
                slot-scope="{ item, index }"
            >
              <slot name="label" :item="item" :index="index"></slot>
            </div>
            <div slot="foot"
                 v-if="columnsData.columns.footSlot"
                 slot-scope="{ item, index }"
            >
              <slot name="foot" :item="item" :index="index"></slot>
            </div>
          </pageList>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import pageList from "../../components/pageList/pageListz";

export default {
  props: {
    columnsData: {
      type: Object,
      default: function () {
        return {};
      },
    },
    selectLattice:{
      type: Boolean,
      default: false
    }
  },
  computed: {},
  components: {
    pageList,
  },
  data() {
    return {};
  },
  methods: {
    goBack() {
      this.$emit("goBack");
    },
    listData(v) {
      console.log(v,'vvv');
      this.$emit("listData", v);
    },
    // 获取选择的列表数据
    getCheckedValue(ids, item) {
      if (!item.length) {
        this.$toast('请选择数据')
        return
      }

      let validItems = item.filter(ele => ele.outboundQuantity <= 0 || ele.outboundQuantity === '')
      console.log(validItems, 'validItemsvalidItems', item)
      let labels = validItems.map(ele => ele.latticeCode + '|' + ele.latticeName)
      if (labels.length) {
        this.$toast('请检查' + labels.join(',') + '的出库数量')
        return;
      }


      this.$emit("getCheckedValue", ids, item);
      this.columnsData.listShow = false;
      this.columnsData.listShow1 = false;
    },
    //列表点击事件
    handleList(id, item, type) {
      this.$emit("handleList", id, item, type);
      if (type !== "更多操作") {
        this.columnsData.listShow = false;
      }
    },
    operationItem(a, b) {
      this.$emit("operationItem", a, b);
    },
    // 加载列表
    getList() {
      // 传1代表从第一条数据开始
      this.$refs.pageList.onLoad(1);
    },
    // 搜索
    searchQuery(v) {
      // 搜索条件
      this.$refs.pageList.searchQuery(v);
    },
    // 重置
    searchReset() {
      this.$refs.pageList.searchReset();
    },
  },
  watch: {},
};
</script>

<style lang="scss" scoped>
@import "@/assets/theme.scss";
@import "@/views/workManagement/materialRequisition/materialDetail.scss";
@import "@/views/workManagement/materialRequisition/materialForm.scss";

.action {
  background: #f5f5f5;

  .title {
    position: sticky;
    top: 0;
    z-index: 999;
  }
}

/deep/ .operation {
  background: #ffffff !important;
}

.listBox {
  height: calc(100vh - 300px);
  overflow-y: auto;
}

.wrap {
  background: #fff;
  padding: 20px;

  .pd {
    padding: 0 20px;
  }

  .top {
    display: flex;
    justify-content: flex-start;

    .icon {
      width: 6px;
      height: 36px;
      background: #1890ff;
      margin-top: 6px;
      margin-right: 20px;
    }

    .title {
      width: 620px;
      margin-right: 20px;
      font-size: 32px;
      font-family: PingFang SC;
      font-weight: 500;
      color: #191f25;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .title-m {
      margin-left: 0.3rem;
    }

    .spot img {
      width: 40px;
      height: 40px;
    }
  }

  .center {
    p {
      margin: 16px 0px;
      font-size: 28px;
      display: flex;
      position: relative;

      .key {
        color: #888888;
      }

      .value {
        color: #191f25;
        width: 380px;
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .arrow {
        color: #1890ff;
        // float: right;
        // margin-right: -0.05rem;
        // display: block;
        position: absolute;
        right: -10px;
      }
    }

    .showAll {
      background: #f5f8ff;
      width: 100vw;
      margin-left: -0.15rem;
      padding: 0.15rem;
      margin-bottom: 0.15rem;
    }

    .fontAno {
      font-size: 30px;
      padding-left: 20px;
    }
  }

  .label {
    margin-left: -6px;
    margin-top: -20px;

    span {
      height: 0.62667rem;
      background: #f0f6fe;
      color: #1890ff !important;
      margin-right: 20px;
      padding: 6px 16px;
      font-size: 22px;
      border-radius: 6px;
    }
  }

  .gap {
    height: 6px;
    background-color: #eee;
  }

  .foot {
    // height: 0.33rem;
    // line-height: 0.33rem;
    display: flex;
    justify-content: space-between;
    // margin: 0.15rem 0.12rem 0 0.12rem;
    font-size: 0.14rem;

    .pictures {
      width: 0.33rem;
      height: 0.33rem;
      line-height: 0.33rem;
      text-align: center;
      color: #fff;
      background: #1890ff;
      display: block;
      border-radius: 0.06rem;
      font-size: 0.12rem;
      margin-right: 0.1rem;
    }

    .text {
      width: 1rem;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .opera {
      color: #1890ff;
      font-size: 0.14rem;
    }
  }
}

</style>
